import pandas as pd
import numpy as np

#myTeam='COL'
#myYear='2013'
#minAB = 100

#pl['TB']=pd.Series((pl.H+1.*pl['2B']+2.*pl['3B']+3.*pl.HR))
#pl['G']=pl['G'].astype('int64')
#pl.to_csv('/tmp/mynew.csv',sep='\t',float_format="%.3f",index=False,header=True,columns=['playerID','BA','SLG','OBA','G','AB','R','H','TB','2B','3B','HR','RBI','BB','SO','SB','CS','E'])

def getLastName(allPlayers,thesePlayers):
  tmp = allPlayers.reset_index().set_index('playerID')
  return tmp.loc[thesePlayers['playerID'].values,'last']

def getFirstName(allPlayers,thesePlayers):
  tmp = allPlayers.reset_index().set_index('playerID')
  return tmp.loc[thesePlayers['playerID'].values,'first']

def getTeam(allTeams,allPlayers,thesePlayers):
  tmp1 = allPlayers.reset_index().set_index('playerID')
  tmp2 = allTeams.reset_index().set_index('teamID')
  theseTeams = tmp1.loc[thesePlayers['playerID'].values,'teamID']
  return tmp2.loc[theseTeams.values,'schoolName']

mySplits=pd.read_csv('2014DivOneBattingSplits.csv')
myPlayers=pd.read_csv('collegePlayerKeys.csv')
myTeams = pd.read_csv('collegeTeamKeys.csv')

risp=mySplits[(mySplits['splitType']=='RISP') & (mySplits['RBI']>30)]
risp['RISPBA']=pd.Series(risp.H/risp.AB)
risp['RISPRBI']=pd.Series(risp.RBI/risp.AB)
highrisp=risp[risp['RISPRBI']>0.6]
